import ReactDOM from 'react-dom';
import React from 'react';
import {HashRouter,Route,IndexRoute,Switch} from 'react-router-dom';
import {Header,NoMatch} from './Components'
import {routes} from './router/router.config'
import 'element-theme-default';
import {Provider} from 'react-redux';
//保存store状态的配置
import configureStore from './store';
import { PersistGate } from 'redux-persist/lib/integration/react'
let {store,persistor} = configureStore();



ReactDOM.render(
  // 所有的路由通过store传递
  <Provider store={store}>
   <PersistGate loading={null} persistor={persistor}>
    <HashRouter>
          <div>
            <Header/>
          
            <Switch>
              {
                routes.map((route,index)=>
                <Route key={index} path={route.path} component={route.component} exact={route.exact}/>
              )
              }
              <Route component={NoMatch} />
            </Switch>
          </div>
        </HashRouter>
        </PersistGate>
      </Provider>,
     document.getElementById('app'))